<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<style>
.goods_attr ul{
	width:100%;
	list-style:none;
	line-height:20px;
}
.goods_attr ul .type{width:50px;float:left;margin-right:15px;font-weight: bold;}
.goods_attr ul .value{width:80px;float:left;margin-right:10px;}
.goods_spec ul{
	list-style:none;
}
.goods_spec ul .spec_class{line-height:40px;width:50px;margin-right:15px;font-weight: bold;}
.goods_spec ul .spec_value{height:40px;width:130px;float:left;margin-right:10px;border: 1px solid #ccc;padding:2px 4px;}
.goods_spec ul .spec_left{float: left;width: 40px;line-height:20px;font-size: 14px}
.goods_spec ul .spec_right{float: right;width: 75px;line-height:40px;}
</style>
<div style="display: none"><script id="_goods_img" type="text/plain"></script></div>  
<div class="pageContent">
	<form method="post" id="goodsFormId" action="${rootUrl}/goods/goods<c:if test="${goods.id != ''}">/${goods.id}</c:if>" class="pageForm required-validate" onsubmit="return validateCallback(this, saveCallBack);">
		<input type="hidden" name="_method" value="put"> 
		<div class="pageFormContent" layoutH="56">
			<input name="goods.id" id="goodsId" type="hidden" size="30" value="${goods.id}" />
			<input name="goods.version" id="versionId" type="hidden" size="30" value="${goods.version}" />
			<p>
				<label>商品名称：</label>
				<input name="goods.name" class="required" type="text" size="30" value="${goods.name}" />
			</p>

			<p>
				<label>商品标题：</label>
				<input name="goods.title"  type="text" size="30" value="${goods.title}" />
			</p>
			<p>
				<label>类别：</label>
				<input name="goods.goodsClass.name" class="required" readonly="readonly" type="text" value="${goods.goodsClass.name }" />
				<input type="hidden" name="goods.goodsClass.id" value="${goods.goodsClass.id }">
				<a class="btnLook" href="${rootUrl}/goods/goods-class/1/showAll" lookupGroup="goods.goodsClass">类别</a>
			</p>
			<p>
				<label>品牌：</label>
				<input name="goods.brand.name" readonly="readonly" class="required" type="text" value="${goods.brand.name }" />
				<input type="hidden" name="goods.brand.id" value="${goods.brand.id }">
				<a class="btnLook" href="${rootUrl}/goods/brand/0/dialog" lookupGroup="goods.brand">品牌</a>
			</p>
			<p>
				<label>商家：</label>
				<input type="hidden" id="sellerId" name="goods.seller.id" value="${goods.seller.id}"/>
				<input type="text" style="float:left" readonly="readonly" class="required" id="sellerName" name="goods.seller.name" value="${goods.seller.name}"/>
				<a class="btnLook" href="${rootUrl}/seller/seller/1/dialog" width="800" height="720" lookupGroup="goods.seller">商家</a>
			</p>
			<p>
				<label>仓库：</label>
				<input name="goods.storage.name" readonly="readonly" class="required" type="text" value="${goods.storage.name }" />
				<input type="hidden" name="goods.storage.id" value="${goods.storage.id }">
				<a class="btnLook" href="${rootUrl}/seller/storage/0/dialog?sellerId={sellerId}" warn="请选择商家" lookupGroup="goods.storage">仓库</a>
			</p>
			<p>
				<label>总库存：</label>
				<input name="goods.inventory" readonly="readonly" type="text" size="30" value="${goods.inventory}" />
			</p>
			<p>
				<label>运费：</label>
				<select  name="goods.isFreight">
				<option <c:if test="${goods.isFreight == 1}">selected="selected"</c:if> value="1">正常</option>
				<option <c:if test="${goods.isFreight == 0}">selected="selected"</c:if> value="0">免运费</option>
				</select>
			</p>
			<p>
				<label>虚拟商品：</label>
				<select  name="goods.isVirtual">
				<option <c:if test="${goods.isVirtual == 0}">selected="selected"</c:if> value="0">否</option>
				<option <c:if test="${goods.isVirtual == 1}">selected="selected"</c:if> value="1">是</option>
				</select>
			</p>
			<p>
				<label>商品状态：</label>
				<select  name="goods.state">
				<c:if test="${goods.state == null || goods.state < 10}">
					<option <c:if test="${goods.state == 1}">selected="selected"</c:if> value="1">正常</option>
					<option <c:if test="${goods.state == 0}">selected="selected"</c:if> value="0">下架</option>
					<option <c:if test="${goods.state == 3}">selected="selected"</c:if> value="3">赠品</option>
				</c:if>
				<c:if test="${goods.state > 10}">
					<c:if test="${goods.state == 11}"><option value="11">正常待审核</option></c:if>
					<c:if test="${goods.state == 13}"><option value="13">赠品待审核</option></c:if>
				</c:if>
				</select>
			</p>
			<p>
				<label>显示价格：</label>
				<input class="listMoneyField" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value='${goods.price/100}' pattern='0.00'/>" />
			</p>
			<p>
				<label>会员价格：</label>
				<input class="listMoneyField" readonly="readonly" type="text" size="30" value="<fmt:formatNumber value='${goods.price2/100}' pattern='0.00'/>" />
			</p>
			<p>
				<label>所需积分：</label>
				<input class="listMoneyField" name="goods.points" readonly="readonly" type="text" size="30" value="${goods.points}" />
			</p>
			<dl class="nowrap">
				<dt>商品规格：</dt>
				<dd style="width: 1024px;" class="goods_spec">
				<a class="btnLook" href="javascript:openGoodsSpec()">编辑规格</a>
				<!-- 
				<br/>
				<c:forEach items="${goodsSpecs}" var="goodsSpec" varStatus="status">
					<ul><li class="spec_class">${goodsSpec.specClassName }</li>
					<c:forEach items="${goodsSpec.goodsSpecValue}" var="goodsSpecValue" varStatus="status2">
						<li class="spec_value"><span class="spec_left">图片</span><span class="spec_right">${goodsSpecValue.specName }</span></li>
					</c:forEach>
					</ul>
				</c:forEach> -->
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>商品属性：</dt>
				<dd class="goods_attr">
				<a class="btnLook" href="javascript:openGoodsAttr()">编辑属性</a>
				<!-- 
				<br/>
				<ul>
				<li class="type">asdf:</li><li class="value">22222222222</li>
				<li class="type">asdf:</li><li class="value">22222222222</li>
				<li class="type">asdf:</li><li class="value">22222222222</li>
				</ul> -->
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>商品类型：</dt>
				<dd class="goods_attr">
				<a class="btnLook" href="javascript:openGoodsTypeValue()">编辑类型</a>
				<!-- 
				<br/>
				<ul>
				<li class="type">asdf:</li><li class="value">22222222222</li>
				<li class="type">asdf:</li><li class="value">22222222222</li>
				<li class="type">asdf:</li><li class="value">22222222222</li>
				</ul> -->
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>商品主图片：</dt>
				<dd>
				<input name="goods.image" id="goods_img_url"  type="hidden" size="30" value="${goods.image}" />
				<div class="imgContainer"><a href="#" onclick="iFileUploader.upImg('goods_img_url','goods_img');"><img id="goods_img" src="${goods.image}" /></a></div>
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>图片列表：</dt>
				<dd class="goods_attr">
				<a class="btnLook" href="javascript:openGoodsImageList()">编辑图片列表</a>
				<!-- 
				<br/>
				<ul>
				<li class="type">asdf:</li><li class="value">22222222222</li>
				<li class="type">asdf:</li><li class="value">22222222222</li>
				<li class="type">asdf:</li><li class="value">22222222222</li>
				</ul> -->
				</dd>
			</dl>
			<p>
				<label>点击次数：</label>
				<input name="goods.click"  type="text" readonly="readonly" size="30" value="${goods.click}" />
			</p>
			<p>
				<label>总销量：</label>
				<input name="goods.salenum"  type="text" readonly="readonly" size="30" value="${goods.salenum}" />
			</p>
			<p>
				<label>收藏数：</label>
				<input name="goods.collect"  type="text" readonly="readonly" size="30" value="${goods.collect}" />
			</p>
			<p>
				<label>评价数：</label>
				<input name="goods.evaluationCount"  type="text" readonly="readonly" size="30" value="${goods.evaluationCount}" />
			</p>
			<p>
				<label>审核状态：</label>
				<input type="text" readonly="readonly" size="30" value="<c:if test="${goods.verify == 10 || goods.verify == null}">审核中</c:if>
<c:if test="${goods.verify == 1}">通过</c:if><c:if test="${goods.verify == 0}">未通过</c:if>" />
				<input name="goods.verify"  type="hidden" size="30" value="<c:if test="${goods.verify == null}">10</c:if><c:if test="${goods.verify != ''}">${goods.verify}</c:if>" />
			</p>
			<dl class="nowrap">
				<dt>审批备注：</dt>
				<dd><textarea name="goods.verifyRemark" cols="150" readonly="readonly" rows="5">${goods.verifyRemark}</textarea></dd>
			</dl>
			<p>
				<label>添加时间：</label>
				<input name="goods.addTime" type="text" size="30" value="<fmt:formatDate value="${goods.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly="readonly"/>
				<a class="inputDateButton" href="javascript:;">选择</a>
			</p>
			<p>
				<label>上架时间：</label>
				<input name="goods.sellTime"  type="text" size="30" value="<fmt:formatDate value="${goods.sellTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly="readonly"/>
				<a class="inputDateButton" href="javascript:;">选择</a>
			</p>
			<p>
				<label>最后编辑时间：</label>
				<input name="goods.editTime"  type="text" size="30" value="<fmt:formatDate value="${goods.editTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" readonly="readonly"/>
				<a class="inputDateButton" href="javascript:;">选择</a>
			</p>
<dl class="nowrap">
				<dt>商品描述：</dt>
				<dd style="width: 1024px;height: 500px;"><div>
				<script id="goods_detail" name="goods.detail" type="text/plain">${goods.detail}</script></div>
				</dd>
			</dl>
		</div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">保存</button></div></div></li>
				<li>
					<div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div>
				</li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
	var uploadFolder = 1;
   	var pHeight = $("#goods_detail").parent().css("height");
   	var editor = new UE.ui.Editor({initialFrameHeight:450,initialFrameWidth:'100%'});
   	editor.options.zIndex = 0;
   	editor.render("goods_detail");
   	editor.ready(function () {
		this.execCommand('serverparam', 'imageFolder', uploadFolder);//返回参数值键值对的对象
	 });
   	//editor.execCommand('serverparam', 'imageFolder', uploadFolder);
   	/**var zindex = $.pdialog._current.css("z-index");
   	editor.addListener('beforefullscreenchange',function(event,isFullScreen){
	  if(!isFullScreen){
	   $.pdialog._current.css("z-index",zindex);
	  }
   	});**/
   	iFileUploader.initImg("_goods_img","goods_img_url","goods_img",{imageFolder:uploadFolder});
   	
   	function openGoodsSpec(){
   		if($("#goodsId").val() != 0){
   			$.pdialog.open("${rootUrl}/goods/goods-spec?goodsId="+$("#goodsId").val(),"goods_spec_class","产品规格",{width:800,height:600});
   		}else{
   			alert("在保存过商品后才可添加规格");
   		}
   	}
	function openGoodsAttr(){
   		if($("#goodsId").val() != 0){
   			$.pdialog.open("${rootUrl}/goods/goods-attr-value?goodsId="+$("#goodsId").val(),"goods_attr_value","产品属性",{width:800,height:600});
   		}else{
   			alert("在保存过商品后才可添加属性");
   		}
   	}
	function openGoodsTypeValue(){
   		if($("#goodsId").val() != 0){
   			$.pdialog.open("${rootUrl}/goods/goods-type-value?goodsId="+$("#goodsId").val(),"goods_type_value","产品类型",{width:800,height:600});
   		}else{
   			alert("在保存过商品后才可添加类型");
   		}
   	}
	
	function openGoodsImageList(){
   		if($("#goodsId").val() != 0){
   			$.pdialog.open("${rootUrl}/goods/goods-image?goodsSpecClassId=0&goodsId="+$("#goodsId").val(),"goods_image_index","商品图片列表",{width:860,height:600});
   		}else{
   			alert("在保存过商品后才可添加类型");
   		}
   	}
   	function saveCallBack(json){
   		if($("#goodsId").val() == ""){
			$("#goodsFormId").attr("action",$("#goodsFormId").attr("action")+"/"+json.goodsId);
   		}
		$("#goodsId").val(json.goodsId);
		$("#versionId").val(json.version);
   		DWZ.ajaxDone(json);
   	}
</script>